fix: gate search tool registration on TAVILY_API_KEY presence#621
Conversation
The search tool was registered unconditionally in getTools(), so the LLM would attempt to call it even when TAVILY_API_KEY was unset. The Tavily client then errored inside execute(), and the UI rendered "An error occurred while searching for..." for any search-y query, regardless of whether the deployment intended search to be enabled. Match the existing SERPER_API_KEY pattern in the same file's videoSearch registration: only register the tool when its required key is present. The LLM then answers from its own knowledge for queries that would have triggered search, with no misleading error card. Also adds TAVILY_API_KEY to .env.local.example with a note documenting the runtime behavior when unset.
|
@itsautomata is attempting to deploy a commit to the QCX-MAIN Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis PR makes the Tavily search tool optional by gating its registration on the ChangesOptional Search Tool Integration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This PR matches the existing
SERPER_API_KEYgating pattern (lib/agents/tools/index.tsx:31) forTAVILY_API_KEY, so the search tool is only registered when its required key is present. Previously the LLM would attempt search even on deployments without Tavily configured, surfacing "An error occurred while searching for..." in the UI on any search-y query without providing any further explanation.Key Changes
searchonly whenTAVILY_API_KEYis set, matching the existing pattern used forvideoSearch+SERPER_API_KEY.TAVILY_API_KEYentry with a comment noting the runtime behavior when unset.Summary by CodeRabbit
Documentation
Chores